package com.hanlin.topic;

import com.hanlin.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * 描述：topic模式的生产者
 *
 * @author:hl.yuan
 * @date:2021-03-13
 */
public class SendRabbitMQ {

    public static void main(String[] args) throws IOException {
        Connection connection = RabbitUtils.getConnection();

        Channel channel = connection.createChannel();
        // 创建交换机
        channel.exchangeDeclare("topics","topic");

        String key = "user.save.findAll";

        channel.basicPublish("topics",key,null,("这是路由中的动态订阅模型,route key: ["+key+"]").getBytes());


        RabbitUtils.closeConnection(channel,connection);

    }


}
